home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
COMMUNIC
/
TERMINAL
/
1589.ZIP
/
TERMDLG.C
< prev
next >
Wrap
Text File
|
1989-04-13
|
12KB
|
381 lines
#include "windows.h"
#include <stdio.h>
#include "icu_user.h"
#include "term.h"
/**/
/*doc************************************************************************
*
* NAME
*
* DescDlg() - Use to display and log error and diag. messages.
* I use it for debugging.
*
* FORMAT
*
* DESCRIPTION
*
* RETURN VALUE
*
* MODIFIES
*
* REFERENCES
*
*end************************************************************************/
BOOL FAR PASCAL DescDlg(hWndDlg, message, wParam, lParam)
HWND hWndDlg;
unsigned message;
WORD wParam ;
LONG lParam ;
{
/****************************************
* start of function code *
****************************************/
switch (message) {
case WM_CREATE:
PostMessage(hWdesc, WM_COMMAND, IDDPB2, (LONG) 0);
break;
case WM_COMMAND:
switch(wParam) {
case IDOK: /* Take window down */
ShowWindow(hWndDlg,SW_HIDE);
break;
case IDDPB1: /* Refresh list box */
SendDlgItemMessage (hWdesc,IDDLIST,LB_RESETCONTENT,0,0L);
break;
case IDDPB2: /* Toggle Verbose messages */
VerboseMessages = IsDlgButtonChecked(hWndDlg,IDDPB2);
break;
case IDDPB3: /* Toggle error logging */
LogErrors = IsDlgButtonChecked(hWndDlg,IDDPB3);
break;
default:
return FALSE;
break;
} /* End Switch(wParam) */
break; /* End case WM_COMMAND: */
default:
return FALSE;
break;
} /* End switch(message) */
return(TRUE);
}
/**/
/*doc************************************************************************
*
* NAME
*
* SelectDlg() - dialog box to input name for the configuration file
*
* FORMAT
*
* BOOL FAR PASCAL SelectDlg(hWndDlg, message, wParam, lParam)
* HWND hWndDlg;
* unsigned message;
* WORD wParam;
* LONG lParam;
*
* DESCRIPTION
* Displays all files ending with .cnf. Allows the user to select
* which configuration file to use.
*
* RETURN VALUE
*
* MODIFIES
* ConfigFile
*
* REFERENCES
*
*end************************************************************************/
BOOL FAR PASCAL SelectDlg(hWndDlg, message, wParam, lParam)
HWND hWndDlg;
unsigned message;
WORD wParam ;
LONG lParam ;
{
/****************************************
* local variable declarations *
****************************************/
int i, ret, hdl;
char temp_str[14];
char path[120];
/****************************************
* start of function code *
****************************************/
switch (message) {
case WM_INITDIALOG:
SetDlgItemText(hWndDlg,IDDREQTYPE,(LPSTR)"Path:");
SetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)"*.CNF");
DlgDirList(hWndDlg,(LPSTR)"c:*.CNF",IDDIMGLIST,IDDPATHNAME,0x4010);
break; /* end case WM_INITDIALOG */
case WM_COMMAND:
switch( wParam ) {
/****************************************/
case IDOK: /* user hit Select button */
/****************************************/
if (!GetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)ConfigPath,59))
return( FALSE );
EndDialog(hWndDlg,TRUE);
break;
case IDDIMGLIST:
if (HIWORD(lParam) == LBN_DBLCLK) {
if ( DlgDirSelect(hWndDlg,(LPSTR)temp_str,IDDIMGLIST) ) {
strcpy(path,temp_str); /* user selected a directory */
if (temp_str[1] == ':')
strcat(path,"\\*.cnf");
else
strcat(path,"*.cnf");
SetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)"*.cnf");
ret = DlgDirList(hWndDlg,(LPSTR)path,IDDIMGLIST,IDDPATHNAME,0x4010);
}
else { /* user selected a file name */
SetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)temp_str);
SendMessage(hWndDlg,WM_COMMAND,IDOK, lParam); /* Push OK Button */
}
}
else if (HIWORD(lParam) == LBN_SELCHANGE) { /* user clicked string*/
if ( DlgDirSelect(hWndDlg,(LPSTR)temp_str,IDDIMGLIST) ) {
strcpy(path,temp_str);
if (temp_str[1] == ':')
strcat(path,"\\*.cnf");
else
strcat(path,"*.cnf");
SetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)path);
}
else /* user selected a file name */
SetDlgItemText(hWndDlg,IDDREQSTRG,(LPSTR)temp_str);
}
break;
/*****************************************/
/* user wants to cancel his page request */
/*****************************************/
case IDCANCEL:
EndDialog(hWndDlg,FALSE);
break;
default:
return(FALSE);
break;
} /* End case WM_COMMAND: switch( wParm ) */
break; /* End case WM_COMMAND */
default:
return(FALSE);
break;
}
return(TRUE);
}
/**/
/*doc************************************************************************
*
* NAME
*
* TermAboutDlg() - dialog box for ABOUT info
*
* FORMAT
*
* BOOL FAR PASCAL TermAboutDlg(hWndDlg, message, wParam, lParam)
* HWND hWndDlg;
* unsigned message;
* WORD wParam;
* LONG lParam;
*
* DESCRIPTION
* Displays information about TERMINAL
*
* RETURN VALUE
*
* MODIFIES
*
* REFERENCES
*
*end************************************************************************/
BOOL FAR PASCAL TermAboutDlg(hWndDlg, message, wParam, lParam)
HWND hWndDlg;
unsigned message;
WORD wParam ;
LONG lParam ;
{
switch (message)
{
case WM_INITDIALOG:
/* must return TRUE to this msg, and we do below */
break;
case WM_COMMAND:
switch (wParam)
{
case IDOK:
case IDCANCEL:
EndDialog(hWndDlg, TRUE);
break;
default:
return FALSE;
}
default:
return FALSE;
}
return TRUE;
}
/**/
/*doc************************************************************************
*
* NAME
*
* ConfigTerm() - dialog box used to allow the user to change the terminal
* configuration
*
* FORMAT
*
* BOOL FAR PASCAL ConfigTerm(hWndDlg, message, wParam, lParam)
* HWND hWndDlg;
* unsigned message;
* WORD wParam;
* LONG lParam;
*
* DESCRIPTION
* Allows the user to modify the terminal settings that were set
* when the configuration file was loaded.
*
* RETURN VALUE
*
* MODIFIES
*
* REFERENCES
*
*end************************************************************************/
BOOL FAR PASCAL ConfigTerm(hWndDlg, message, wParam, lParam)
HWND hWndDlg;
unsigned message;
WORD wParam ;
LONG lParam ;
{
int i, h, w;
static baud, fontsize, comm, iconmode;
TEXTMETRIC tm;
/****************************************
* start of function code *
****************************************/
switch (message) {
case WM_INITDIALOG:
baud = baud_rate;
iconmode = message_action;
if ( baud_rate == 300 ) i = IDD300 ;
else if ( baud_rate == 1200 ) i = IDD1200;
else i = IDD9600;
CheckRadioButton( hWndDlg, IDD300, IDD9600,i );
if ( char_w == 11 && char_h == 11 ) i = IDDSMALL;
else if ( char_w == 22 && char_h == 11 ) i = IDDMED1 ;
else if ( char_w == 11 && char_h == 22 ) i = IDDMED2 ;
else i = IDDLARGE;
CheckRadioButton( hWndDlg, IDDSMALL, IDDLARGE, i );
comm = atoi( port_name+3 );
if ( comm == 1 ) i = IDDCOM1;
else if ( comm == 2 ) i = IDDCOM2;
else if ( comm == 3 ) i = IDDCOM3;
else if ( comm == 4 ) i = IDDCOM4;
CheckRadioButton( hWndDlg, IDDCOM1, IDDCOM4, i );
if ( message_action == MSG_FLASH ) i = IDDFLASH ;
else if ( message_action == MSG_BEEP ) i = IDDBEEP ;
else if ( message_action == MSG_DISP ) i = IDDDISPLAY;
else i = IDDOPEN ;
CheckRadioButton( hWndDlg, IDDFLASH, IDDOPEN, i );
break;
case WM_COMMAND:
switch( wParam ) {
case IDD300:
case IDD1200:
case IDD9600:
if ( wParam == IDD300 ) baud = 300;
else if ( wParam == IDD1200 ) baud = 1200;
else baud = 9600;
CheckRadioButton( hWndDlg, IDD300, IDD9600, wParam );
break;
case IDDSMALL:
case IDDMED1:
case IDDMED2:
case IDDLARGE:
if ( wParam == IDDSMALL ) { w = 8; h = 8; }
else if ( wParam == IDDMED1 ) { w = 22; h = 11; }
else if ( wParam == IDDMED2 ) { w = 11; h = 22; }
else if ( wParam == IDDLARGE ) { w = 22; h = 22; }
w *= (no_cols + 6); /* Size window acording to new font */
h *= (no_lines + 6);
GetWindowRect(hWndTerm,(LPRECT)&rect);
MoveWindow( hWndTerm, rect.left, rect.top, w, h, TRUE);
if ((rect.right-rect.left > GetSystemMetrics(SM_CXICON)+10) ||
(rect.bottom-rect.top > GetSystemMetrics(SM_CYICON)+10)) {
CopyRect((LPRECT)&win_sz.size,(LPRECT)&rect);
}
CheckRadioButton( hWndDlg, IDDSMALL, IDDLARGE, wParam );
break;
case IDDCOM1:
case IDDCOM2:
case IDDCOM3:
case IDDCOM4:
if ( wParam == IDDCOM1 ) comm = 1;
else if ( wParam == IDDCOM2 ) comm = 2;
else if ( wParam == IDDCOM3 ) comm = 3;
else comm = 4;
CheckRadioButton( hWndDlg, IDDCOM1, IDDCOM4, wParam );
break;
case IDDFLASH:
case IDDBEEP:
case IDDDISPLAY:
case IDDOPEN:
if ( wParam == IDDFLASH ) iconmode = MSG_FLASH;
else if ( wParam == IDDBEEP ) iconmode = MSG_BEEP ;
else if ( wParam == IDDDISPLAY ) iconmode = MSG_DISP ;
else iconmode = MSG_OPEN ;
CheckRadioButton( hWndDlg, IDDFLASH, IDDOPEN, wParam );
break;
case IDOK:
sprintf( port_name, "COM%d:", comm );
baud_rate = baud;
message_action = iconmode;
CloseComm(nCID);
i = TRUE; /* Reopen the comm port with new speed & number */
if ( TermOpenComm() == FALSE ) {
fileput("Unable to re-open the communications port");
i = FALSE;
}
EndDialog( hWndDlg, i );
break;
case IDCANCEL:
EndDialog( hWndDlg, FALSE );
break;
default:
return( FALSE );
}
break;
default:
return( FALSE );
}
return( TRUE );
}